package com.health.controller;

import com.health.common.Result;
import com.health.entity.pojo.dto.QueryAdminLogDTO;
import com.health.service.IAdminLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author health
 * @since 2023-04-21
 */
@Api(tags = "后端日志管理")
@RestController
@RequestMapping("/adminLog")
public class AdminLogController extends BaseController{

    @Autowired
    IAdminLogService iAdminLogService;


    @PostMapping("/listPageAdminLog")
    @ApiOperation("分页查询后端日志信息")
    public Result listPageAdminLog(@RequestBody QueryAdminLogDTO queryAdminLogDTO){
        return dataResult(iAdminLogService.listPageAdminLog(queryAdminLogDTO));
    }

    @DeleteMapping("/deleteBathcAdminLog")
    @ApiOperation("批量删除日志记录")
    public Result deleteBathcAdminLog(@RequestBody List<Integer> ids){
       if(ids.size() > 1)
           return booleanResult(iAdminLogService.removeBatchByIds(ids));
       if(ids.size() == 1)
           return booleanResult(iAdminLogService.removeById(ids.get(0)));
       return error();
    }
}
